The following properties allow you to style and format text-based views, such as Text
or Label
, in ways that closely mirror SwiftUI’s built-in modifiers. By customizing these properties, you can control the font, weight, design, spacing, and other typographic attributes of the displayed text.
These properties are generally passed to text-related views like Text
or Label
components as attributes. For example, you can specify a font size, enable bold formatting, or add an underline with a custom color—all without manually calling multiple modifiers.
In the example above, the text uses a custom font, semibold weight, italic style, a red underline, limits to two lines, and centers the text.
font
Defines the font and size to apply to the text.
14
), it applies the system font at that size.Font
type): Use one of the built-in text styles ("largeTitle"
, "title"
, "headline"
, "subheadline"
, "body"
, "callout"
, "footnote"
, "caption"
). The system determines the size and weight based on that style.name
and size
.fontWeight
Sets the thickness of the font’s stroke. Options range from "ultraLight"
to "black"
.
fontWidth
Specifies the width variant of the font if available. Possible values include "compressed"
, "condensed"
, "expanded"
, and "standard"
. You can also use a numeric value if supported.
fontDesign
Modifies the font design. Options include "default"
, "monospaced"
, "rounded"
, "serif"
.
minScaleFactor
A number between 0 and 1 that indicates how much the text can shrink if it doesn’t fit the available space. For example, 0.5
means the text can shrink down to 50% of its original size to fit.
bold
Applies a bold font weight if true
.
baselineOffset
Adjusts the text’s vertical position relative to its baseline. Positive values move the text up, negative values move it down.
kerning
Controls the spacing between characters. A positive value increases spacing; a negative value decreases it.
italic
Applies an italic style if true
.
monospaced
Forces all child text to use a monospaced variant, if available.
monospacedDigit
Uses fixed-width digits while leaving other characters as they are. This helps align numbers vertically, useful for tables or timers.
strikethrough
Applies a strikethrough (line through the text). You can provide a color, or an object specifying a pattern and color.
strikethrough="red"
strikethrough={{ pattern: 'dash', color: 'blue' }}
underline
Applies an underline in a similar way to strikethrough
.
underline="blue"
underline={{ pattern: 'dashDot', color: 'green' }}
lineLimit
Specifies how many lines of text can display. You can provide:
{ min?: number; max: number; reservesSpace?: boolean }
to specify a minimum and maximum number of lines, and whether the text should reserve space for all those lines even when not used.multilineTextAlignment
Sets the text alignment for multi-line text: "leading"
, "center"
, or "trailing"
.
By combining these properties, you can fully control the typography of your text-based views without needing multiple wrapper components or modifiers. Whether you need a bold, italic headline font with custom kerning and underline, or a simple body font that truncates after two lines, these options cover a broad range of text styling needs.